import request from '@/utils/request'
import store from '@/store'
//const ascriptionId = store.state.userInfo.ascriptionId;

// 页面内容 所属行业下拉框 + 树 + 表格数据
export function getPage(queryParams) {
    const data = {
      ascriptionId: store.state.userInfo.ascriptionId,
      currentPage: queryParams.currentPage,
      pagesize: queryParams.pagesize
    }
    return request({
      url: '/getIndustryclassPage',
      method: 'post',
      data: data
    })
}

// 根据 所属行业 获取 行业资源分类（树）
export function getClassTree(val) {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
    industryId: val.industryId,  //所属行业 id
    industry: val.industry,  //所属行业
    topLevel: val.topLevel,  //是否包含行业顶级节点 0-不包含 1-包含
  }
  return request({
    url: '/getIndustryclass',
    method: 'post',
    data: data
  })
}

// 数据列表
export function listData(queryParams) {
    const data = {
      ascriptionId: store.state.userInfo.ascriptionId,
      currentPage: queryParams.currentPage,
      pagesize: queryParams.pagesize,
      keywords: queryParams.keywords,
      dictId: queryParams.dictId,   //行业资源分类 id
      industryId: queryParams.industryId,   //所属行业 id
    }
    return request({
      url: '/getIndustryclassList',
      method: 'post',
      data: data
    })
}

// 新增
export function addData(val) {
  const data = {
    projectContent:{
      ascriptionId: store.state.userInfo.ascriptionId, //机构 id
      industryId: val.industryId, //所属行业 id
      industry: val.industry, //所属行业 选中的文本
      tid: val.tid, //顶级id
      dictId: val.dictId, //上级id
      titleName: val.titleName, //标题名称
      sort: val.sort //位置排序
    }
  }
  data.projectContent.ascriptionId = store.state.userInfo.ascriptionId
  return request({
    url: '/addIndustryclass',
    method: 'post',
    data: data
  })
}

// 获取单条数据
export function getData(theid) {
  const data = {
    theid
  }
  return request({
    url: '/getIndustryclassData',
    method: 'post',
    data: data
  })
}


// 修改
export function updateData(val) {
  const data = {
    projectContent: {
      theid: val.id, //id
      titleName: val.titleName, //标题名称
      sort: val.sort //位置排序
    }
  }
  return request({
    url: '/updateIndustryclass',
    method: 'post',
    data: data
  })
}

// 删除
export function delData(theid) {
  const data = {
    theid
  }
  return request({
    url: '/delIndustryclass',
    method: 'post',
    data: data
  })
}

// 批量删除   idListStr id列表  逗号隔开
export function delMultiData(idListStr) {
  const data = {
    idListStr
  }
  return request({
    url: '/delMultipleIndustryclass',
    method: 'post',
    data: data
  })
}



